#import "ThingSmartSdkPlugin.h"
#import <ThingSmartHomeKit/ThingSmartKit.h>

@implementation ThingSmartSdkPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
  FlutterMethodChannel* channel = [FlutterMethodChannel
      methodChannelWithName:@"thing_smart_sdk"
            binaryMessenger:[registrar messenger]];
  ThingSmartSdkPlugin* instance = [[ThingSmartSdkPlugin alloc] init];
  [registrar addMethodCallDelegate:instance channel:channel];
}

- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
    NSString *method = call.method;
    if ([method isEqualToString:@"getPlatformVersion"]) {
//        result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
        result([@"iOS custom " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
    } else if ([method isEqualToString:@"configSDK"]) {
        [self configSDK];
        result(@"Config success");
    } else if ([method isEqualToString:@""]) {
        result(nil);
    } else if ([method isEqualToString:@""]) {
        result(nil);
    } else if ([method isEqualToString:@""]) {
        result(nil);
    } else if ([method isEqualToString:@""]) {
        result(nil);
    } else {
        result(FlutterMethodNotImplemented);
    }
    return;
}

- (void)configSDK {
    //com.xinliang.iot
//    [[ThingSmartSDK sharedInstance] startWithAppKey:@"agqcw75adq4rs8ekqsxq"
//                                          secretKey:@"u9tkxh7hkqfaca8u5tgptn53tx5nnmf5"];
    //com.xinliang.iottesttwo
    [[ThingSmartSDK sharedInstance] startWithAppKey:@"uga5m5phpmt98yrk43tc"
                                          secretKey:@"fu5uc3cspcnpnqgwrdapmvanrgxqkm88"];
#ifdef DEBUG
    [[ThingSmartSDK sharedInstance] setDebugMode:YES];
#else
#endif
}

@end
